﻿using System;
using System.Globalization;
using System.Text;
using Highchart.Core.ScriptServices;

namespace Highchart.Core
{
    [Serializable]    
    public class AJAXSource
    {
        #region Default Constants
        private const string DefaultSource = "";
        private const int DefaultDelay = 500;
        private const bool DefaultClearAll = false;
        private const bool DefaultOnlyOnce = false;
        private const bool DefaultShift = false;
        private const string DefaultClientId = "";
        #endregion

        #region Properties
        public string Source { get; set; }
        public int Delay { get; set; }
        public bool ClearAll { get; set; }
        public bool OnlyOnce { get; set; }
        public bool Shift { get; set; }
        public string CustomFunction { get; set; }
        public string ClientId { get; set; }
        #endregion

        #region Constructors
        public AJAXSource()
            : this(DefaultSource, DefaultDelay, DefaultClearAll, DefaultOnlyOnce, DefaultShift, DefaultClientId)
        {            
        }

        public AJAXSource(string source)
            : this(source, DefaultDelay, DefaultClearAll, DefaultOnlyOnce, DefaultShift, DefaultClientId)
        {
        }

        public AJAXSource(string source, int delay)
            : this(source, delay, DefaultClearAll, DefaultOnlyOnce, DefaultShift, DefaultClientId)
        {
        }

        public AJAXSource(string source, int delay, bool clearAll, bool onlyOnce, bool shift, string clientId)
        {
            Source = source;
            Delay = delay;
            ClearAll = clearAll;
            OnlyOnce = onlyOnce;
            Shift = shift;
            ClientId = clientId;
        }
        #endregion

        public override string ToString()
        {
            return ScriptBuilder.AjaxSourceScriptBuilder(this);
        }
    }
}